<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;


use app\common\model\LotteryType;

/**
 * 彩种控制器
 */
class Lottery extends AdminBase
{

    /**
     * 快讯彩种列表
     */
    public function LotteryList()
    {

        $where = $this->logicLottery->getWhere($this->param);
        $this->assign('list', $this->logicLottery->getLotteryList($where, 'a.*,c.name as category_name', 'a.create_time desc'));
        $this->assign('cate',LotteryType::all(['status'=>1]));
        $this->assign('param',$this->param);
        return $this->fetch('lottery_list');
    }



    /**
     * 彩种添加
     */
    public function LotteryAdd()
    {

        $this->LotteryCommon();
        $this->assign('cate',LotteryType::all(['status'=>1]));
        return $this->fetch('lottery_edit');
    }

    /**
     * 彩种编辑
     */
    public function LotteryEdit()
    {

        $this->LotteryCommon();

        $info = $this->logicLottery->getLotteryInfo(['a.id' => $this->param['id']], 'a.*,c.name as category_name');

        $this->assign('cate',LotteryType::all(['status'=>1]));
        $this->assign('info', $info);

        return $this->fetch('lottery_edit');
    }








    /**
     * 彩种添加与编辑通用方法
     */
    public function LotteryCommon()
    {

        IS_POST && $this->jump($this->logicLottery->LotteryEdit($_POST));
        $this->assign('param',  $this->param);
    }

    /**
     * 彩种分类添加
     */
    public function LotteryCategoryAdd()
    {

        IS_POST && $this->jump($this->logicLottery->LotteryTypeEdit($this->param));

        return $this->fetch('lottery_category_edit');
    }

    /**
     * 彩种分类编辑
     */
    public function LotteryCategoryeEdit()
    {

        IS_POST && $this->jump($this->logicLottery->LotteryTypeEdit($this->param));

        $info = $this->logicLottery->getLotteryTypeInfo(['id' => $this->param['id']]);
        $this->assign('info', $info);

        return $this->fetch('lottery_category_edit');
    }

    /**
     * 彩种分类列表
     */
    public function LotteryCategoryList()
    {

        $this->assign('list', $this->logicLottery->getLotteryTypeList( []));
        return $this->fetch('lottery_category_list');
    }



    /**
     * 彩种分类删除
     */
    public function LotteryCategoryDel($id = 0)
    {

        $this->jump($this->logicLottery->LotteryTypeDel(['id' => $id]));
    }

    /**
     * 数据状态设置
     */
    public function setStatus()
    {

        $this->jump($this->logicAdminBase->setStatus('Lottery', $this->param));
    }
    /**
     * 数据状态设置
     */
    public function setSort()
    {

        $this->jump($this->logicAdminBase->setSort('Lottery', $this->param));
    }
    /**
     * 数据状态设置
     */
    public function setCatesort()
    {

        $this->jump($this->logicAdminBase->setSort('LotteryType', $this->param));
    }
    /**
     * 数据状态设置
     */
    public function setCatestatus()
    {

        $this->jump($this->logicAdminBase->setStatus('LotteryType', $this->param));
    }

    /**
     * 数据状态设置
     */
    public function update_info()
    {
        $this->jump($this->logicLottery->update_info($this->param));
    }




}
